import { ref } from "vue";

export default function usePaging() {

  const pageable = ref({
    page: 0,
    size: 10
  })

  const setPageable = (page: number, size: number) => {
    pageable.value.page = page
    pageable.value.size = size
  }

  const prevPage = () => {
    if (pageable.value.page) {
      pageable.value.page--;
    }
  }

  const nextPage = () => {
    pageable.value.page++;
  }

  return {
    pageable,
    setPageable,
    prevPage,
    nextPage
  }
}
